package com.uzai.console.web.sysmateiral;

import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.github.xiaoymin.knife4j.annotations.ApiSort;
import com.uzai.console.annotation.SystemLogType;
import com.uzai.console.dto.sysmaterial.SysMaterialDto;
import com.uzai.console.dto.sysmaterial.SysMaterialIdDto;
import com.uzai.console.dto.sysmaterial.SysMaterialQuery;
import com.uzai.console.dto.sysmaterial.SysMaterialUpdateDto;
import com.uzai.console.dto.user.usertype.UserTypeInfoDto;
import com.uzai.console.enums.OperationTypeEnum;
import com.uzai.console.enums.SystemModelEnum;
import com.uzai.console.service.sysmaterial.SysMaterialService;
import com.uzai.console.vo.sysmaterial.SysMaterialVo;
import com.uzai.console.web.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author liuqi
 * @date 2021年08月25日 20:15
 */
@Api(value = "素材管理",tags = "系统设置|素材管理")
@ApiSort(29)
@RestController
public class SysMaterialContoller extends BaseController {
    private Logger logger = LoggerFactory.getLogger(SysMaterialContoller.class);

    @Autowired
    private SysMaterialService sysMaterialService;

    @ApiOperation(value = "分页查询系统素材列表", notes = "分页查询系统素材列表", response = SysMaterialVo.class)
    @ApiOperationSupport(order = 1)
    @PostMapping("/usertype/findSysMaterialList")
    public Object findSysMaterialList(@RequestBody SysMaterialQuery sysMaterialQuery){
        return sysMaterialService.findSysMaterialList(sysMaterialQuery);
    }

    @ApiOperation(value = "查询系统素材详情", notes = "查询系统素材详情", response = SysMaterialVo.class)
    @ApiOperationSupport(order = 1)
    @PostMapping("/usertype/findSysMaterialInfo")
    public Object findSysMaterialInfo(@RequestBody SysMaterialIdDto sysMaterialIdDto){
        return sysMaterialService.findSysMaterialInfo(sysMaterialIdDto);
    }

    @SystemLogType(model = SystemModelEnum.SysMaterial, type = OperationTypeEnum.DELETE)
    @ApiOperation(value = "删除系统素材", notes = "删除系统素材")
    @ApiOperationSupport(order = 2)
    @PostMapping("/usertype/deleteSysMaterial")
    public Object deleteSysMaterial(@RequestBody SysMaterialIdDto sysMaterialIdDto){
        sysMaterialService.deleteSysMaterial(sysMaterialIdDto);
        return true;
    }

    @SystemLogType(model = SystemModelEnum.SysMaterial, type = OperationTypeEnum.ADD)
    @ApiOperation(value = "添加系统素材", notes = "添加系统素材")
    @ApiOperationSupport(order = 3)
    @PostMapping("/usertype/addSysMaterial")
    public Object addSysMaterial(@RequestBody SysMaterialDto sysMaterialDto){
        sysMaterialService.addSysMaterial(sysMaterialDto);
        return true;
    }

    @SystemLogType(model = SystemModelEnum.SysMaterial, type = OperationTypeEnum.ADD)
    @ApiOperation(value = "修改文件名称", notes = "修改文件名称")
    @ApiOperationSupport(order = 4)
    @PostMapping("/usertype/updateSysMaterial")
    public Object updateSysMaterial(@RequestBody SysMaterialUpdateDto sysMaterialUpdateDto){
        sysMaterialService.updateSysMaterial(sysMaterialUpdateDto);
        return true;
    }

}
